from django.db import models


class Category(models.Model):
    """菜谱类别"""
    name = models.CharField(max_length=20, verbose_name='名称')
    parent = models.ForeignKey('self', related_name='subs', null=True, blank=True, on_delete=models.CASCADE,
                               verbose_name='父类别')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'cp_category'
        verbose_name = '菜谱类别'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
